package com.example.practice4.Entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.*;
import java.util.List;

@Data
@NoArgsConstructor
@AllArgsConstructor

@Entity
@Table(name = "t_course")
public class Course {
    @Id
    @Column(name = "name")
    private String name;

    @ManyToMany(targetEntity = Student.class)
    @JoinTable(name= "t_relation"
            //joinColumns,当前对象在中间表的外键
            ,joinColumns = {@JoinColumn(name = "cname",referencedColumnName = "name")}
            //inverseJoinColumns，对方对象在中间表的外键
            ,inverseJoinColumns = {@JoinColumn(name = "sid",referencedColumnName = "id")})
    List<Student> students;
}